package fag.core.game.test.arkanoid;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import fag.core.geometry.Rectangle2D;
import fag.core.geometry.Vector2D;
import fag.core.model.Animation;
import fag.core.model.Frame;
import fag.core.model.Model;
import fag.core.model.SerializableImage;
import fag.core.model.Sprite;

public class BlockModel extends Model {

	private static final long serialVersionUID = 3314152983204450125L;
	
	public BlockModel() {
		
		loadBlockAnimation("blue");
		loadBlockAnimation("brown");
		loadBlockAnimation("gold");
		loadBlockAnimation("grey1");
		loadBlockAnimation("grey2");
		loadBlockAnimation("orange");
		loadBlockAnimation("pink");
		loadBlockAnimation("red");
		loadBlockAnimation("white");
	}
	
	private void loadBlockAnimation(String name) {
		
		Animation a = new Animation(name);
		Frame f1 = new Frame(1000);
		BufferedImage bufferedImage1 = null;
		try {
			bufferedImage1 = ImageIO.read(new File(System.getProperty("user.dir")+"/src/imgs/arkanoid/blocks/" + name + ".png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		Sprite s1 = new Sprite(new SerializableImage(bufferedImage1),new Vector2D());
		Rectangle2D hitbox1 = new Rectangle2D(0, 0, 31, 16);
		f1.setHitbox(hitbox1);
		f1.setSprite(s1);
		f1.updateBounds();
		a.addFrame(f1);
		getListAnimation().add(a);
	}
}
